using System.Collections.Generic;
using NHibernate;
using NHibernate.Criterion;
using Web.Model;

namespace Web.DataAccess
{
    public class CommentsSortedByDateQuery
    {
        private Entity Story { get; set; }
        public CommentsSortedByDateQuery(Entity story)
        {
            Story = story;
        }
        public IList<HeadComment> Load(ISession session)
        {
            return session
                .CreateCriteria<HeadComment>()
                .Add(Restrictions.Eq("Story", Story))
                .AddOrder(Order.Desc("DateCreated"))
                .List<HeadComment>();
        }
    }
}